# -*- encoding:utf8 -*-

class Employee:
    "所有员工的基类"
    empCount = 0

    def __init__(self, name, salary):
        "构造方法"
        self.name = name
        self.salary = salary
        Employee.empCount += 1

    def displayCount(self):
        print "员工总数:%d" % Employee.empCount

    def displayEmployee(self):
        print "员工姓名:", self.name, ",员工薪资:", self.salary

    def __del__(self):
        "析构方法"
        print "析构方法被调用，",self.__class__.__name__,"被回收"

zhangsan = Employee("张三", 8600)
lisi = Employee("李四", "7900")

zhangsan.displayEmployee()
lisi.displayEmployee()
print "员工总数:%d" % Employee.empCount

zhangsan.age = 26
print  hasattr(zhangsan, "age")
print  hasattr(lisi, "age")
print  hasattr(Employee, "age")

print "__dict__:\n", Employee.__dict__
print "__doc__:\n", Employee.__doc__
print "name:\n", Employee.__name__
print "__module__:\n", Employee.__module__
print "__bases__:\n", Employee.__bases__

del zhangsan
del lisi

class Test:
    "测试类的属性和方法"
    __selfId = 0    # 私有变量
    publicAttr = 0  # 公开变量

    def count(self):
        self.__selfId += 1
        self.publicAttr += 1
        print self.__selfId

count = Test()
count.count()
count.count()
print count.publicAttr
# print count.__selfId
print "访问私有变量:",count._Test__selfId
